import { useMemo } from 'react';
import { Table } from 'antd';
import { getPackTableColumns } from '../mconfig';
import { CreateTarget } from '../common/CreateTarget';

export const UpdateMaterialCollectData = ({ dataSource }) => {
  const data = useMemo(() => {
    if (!dataSource?.length) return [];
    // 初始化方法示例
    const target = new CreateTarget();
    target.addTarget(dataSource, 'materialID');
    const getTargets = target.getTarget(true);
    return getTargets;
  }, [dataSource]);

  return (
    <div
      style={{
        height: '100%',
        overflow: 'hidden',
      }}
    >
      <div className={'list-table'}>
        <Table
          size="small"
          bordered={true}
          scroll={{ x: 1300, y: 1000 }}
          style={{ margin: '0' }}
          columns={getPackTableColumns({ finallyType: 'view' })}
          dataSource={data}
        ></Table>
      </div>
    </div>
  );
};
